import path from 'node:path'
import { Menu, Tray } from 'electron'
import { getWindow } from './window'

export const createTray = () => {
  const tray = new Tray(
    path.resolve(
      __dirname,
      '../../resources/windowTray.png',
      // process.platform === 'darwin'
      //   ? '../../resources/macTrayTemplate@2x.png'
      //   : '../../resources/windowTray.png',
    ),
  )
  const contextMenu = Menu.buildFromTemplate([
    { label: '搜索', click: () => {
      getWindow('search').show()
    } },
    { label: '管理', click: () => {
      getWindow('manager').show()
    } },
    { label: '退出', role: 'quit' },
  ])
  tray.setToolTip('代码片段')
  tray.setContextMenu(contextMenu)
}
